#include<bits/stdc++.h>
using namespace std;bool Mbe;
const int SZ=1e7;
char _i[SZ],*_I=_i,_o[SZ],*_O=_o,__[20];
inline int rd(){
	for(;*_I<0x30;_I++);int x=0;
	for(;*_I>0x2f;_I++)x=(x<<1)+(x<<3)+(*_I^0x30);return x;
}
inline void wr(int x){
	int l=0;do __[l++]=0x30|x%10;while(x/=10);
	while(l--)*_O++=__[l];*_O++=0xa;
}
namespace MAOJUN{

const int N=1e6+5;
int n,V=1e6;

multiset<int>sL,sR;
multiset<int>mL[N],mR[N];
const int B=1024,S=N/B+5;
int I[N],L[S],R[S];
int pL[N],pR[N],bL[S],bR[S],as[S];
inline void Mx(int&x,int y){x<y&&(x=y);}
inline void Mn(int&x,int y){x>y&&(x=y);}
inline void main(){
	n=rd();
	memset(pL,0x3f,sizeof pL);memset(bL,0x3f,sizeof bL);memset(as,0x3f,sizeof as);
	memset(pR,0xc0,sizeof pR);memset(bR,0xc0,sizeof bR);int nw=1e9;
	for(int i=1;i<=V;i++)I[i]=(i-1)/B+1;
	for(int i=1;i<=I[V];i++){L[i]=R[i-1]+1;R[i]=R[i-1]+B;}R[I[V]]=V;
	for(int l,r,c=0;n--;){
		for(;*_I<0x30;_I++);
		char o=*_I++;l=rd();r=rd();
		if(o=='A'){
			c++;
			sL.insert(l);mL[l].insert(r);
			if(r<pL[l]){
				int o=I[l];pL[l]=r;
				Mn(as[o],r-*max_element(pR+L[o],pR+l+1));Mn(nw,as[o]);
				if(r<bL[o]){bL[o]=r;Mn(nw,r-*max_element(bR+1,bR+o));}
			}
			sR.insert(r);mR[r].insert(l);
			if(l>pR[r]){
				int o=I[r];pR[r]=l;
				Mn(as[o],*min_element(pL+r,pL+R[o]+1)-l);Mn(nw,as[o]);
				if(l>bR[o]){bR[o]=l;Mn(nw,*min_element(bL+o+1,bL+I[V]+1)-bR[o]);}
			}
		}else{
			c--;
			sL.erase(sL.find(l));mL[l].erase(mL[l].find(r));
			int tr=mL[l].empty()?1e9:*mL[l].begin();bool fl=0;
			if(pL[l]!=tr){
				int o=I[l],mn=1e9;pL[l]=tr;as[o]=1e9;fl=1;
				for(int i=R[o];i>=L[o];i--){Mn(mn,pL[i]);Mn(as[o],mn-pR[i]);}
				bL[o]=mn;
			}
			sR.erase(sR.find(r));mR[r].erase(mR[r].find(l));
			int tl=mR[r].empty()?-1e9:*mR[r].rbegin();
			if(pR[r]!=tl){
				int o=I[r],mx=-1e9;pR[r]=tl;as[o]=1e9;fl=1;
				for(int i=L[o];i<=R[o];i++){Mx(mx,pR[i]);Mn(as[o],pL[i]-mx);}
				bR[o]=mx;
			}
			if(fl){
				nw=as[1];
				for(int i=2,mx=bR[1];i<=I[V];i++){Mn(nw,min(bL[i]-mx,as[i]));Mx(mx,bR[i]);}
			}
		}
		if(c==1)wr(*sR.begin()-*sL.begin());
		else if(nw<1e6)wr(nw);
		else wr(pL[*sL.rbegin()]-pR[*sR.begin()]);
	}
}

}bool Med;int main(){
#ifdef LOCAL
	freopen("down/stone/stone5.in","r",stdin);
	freopen("data.out","w",stdout);
	atexit([]{fprintf(stderr,"%.0lfms\n%lfMB\n",clock()*1000./CLOCKS_PER_SEC,(&Mbe-&Med)/1024./1024);});
#else
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
#endif
	fread(_i,1,SZ,stdin);
	MAOJUN::main();
	fwrite(_o,1,_O-_o,stdout);
	return 0;
}